Skip to content

fix(sort): explicitly clean up temp directory in TmpDirWrapper::Drop#11888

Merged
sylvestre merged 1 commit into
uutils:mainfrom
mattsu2020:sort_fix
Apr 18, 2026
Merged

fix(sort): explicitly clean up temp directory in TmpDirWrapper::Drop#11888
sylvestre merged 1 commit into
uutils:mainfrom
mattsu2020:sort_fix

Conversation

@mattsu2020
Copy link
Copy Markdown
Contributor

@mattsu2020 mattsu2020 commented Apr 17, 2026

Summary

  • TmpDirWrapper::Drop now explicitly calls remove_tmp_dir() before the inner TempDir::Drop runs
  • Previously, Drop only cleared handler state, relying entirely on TempDir::Drop which silently ignores errors via let _ = remove_dir_all()
  • This caused /tmp/uutils_sortXXXX directories to leak, eventually filling /tmp and triggering "disk quota exceeded" errors

Root Cause

The cleanup chain was:

  1. TmpDirWrapper::Drop → clears handler state only (no directory cleanup)
  2. TempDir::Drop → calls remove_dir_all() but silently swallows errors with let _ =

When TempDir::Drop failed (e.g., due to open file handles during error paths), the directory was permanently leaked with no retry or logging.

Closes: #11728

The `TmpDirWrapper::Drop` only cleared handler state without attempting
to delete the temporary directory. Cleanup relied entirely on the inner
`TempDir::Drop`, which silently ignores errors via `let _ =
remove_dir_all()`, potentially leaking `/tmp/uutils_sortXXXX`
directories.

Now `remove_tmp_dir` is called explicitly before `TempDir::Drop` runs,
providing a safety net for cases where the silent cleanup would fail.

Closes: uutils#11728
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.
Congrats! The gnu test tests/cut/bounded-memory is now passing!

@sylvestre sylvestre merged commit 01b7177 into uutils:main Apr 18, 2026
169 checks passed
@mattsu2020 mattsu2020 deleted the sort_fix branch April 19, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sort is filling /tmp with uutils_sortXXXX directories

2 participants